//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    
    clicknum:0,
    imgUrls: [
      'http://img02.tooopen.com/images/20150928/tooopen_sy_143912755726.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175866434296.jpg',
      'http://img06.tooopen.com/images/20160818/tooopen_sy_175833047715.jpg'
    ],
    hotlist:[
      { title:"【2018-02-24】新闻公告标题新闻公告标题1",id:"1"},
      { title: "【2018-02-25】新闻公告标题新闻公告标题2", id: "2" },
      { title: "【2018-02-26】新闻公告标题新闻公告标题新闻公告标题新闻公告标题33", id: "3" },
    ],
    marketcplist:[
      {imgsrc:'../../resource/image/cp1.jpg',name:'产品名称',price:'29.9'},
      { imgsrc: '../../resource/image/cp8.jpg', name: '产品名称',price: '29.9' },
      { imgsrc: '../../resource/image/cp6.jpg', name: '产品名称',price: '29.9' },
      { imgsrc: '../../resource/image/cp1.jpg', name: '产品名称', price: '29.9' },
      { imgsrc: '../../resource/image/cp2.jpg', name: '产品名称', price: '29.9' }
    ],
    goodstorelist:[
      { imgsrc: '../../resource/image/store1.jpg', id:'1' },
      { imgsrc: '../../resource/image/store2.jpg', id: '1' },
      { imgsrc: '../../resource/image/store3.jpg', id: '1' },
      { imgsrc: '../../resource/image/store4.jpg', id: '1' }
    ],
    recommendnav:[
      { name:'冷冻食材',  id: '1' },
      { name: '生鲜食材', id: '1' },
      { name: '米面粮油', id: '1' },
      { name: '酒水饮料', id: '1' },
      { name: '厨房用品', id: '1' },
      { name: 'MORE+', id: '1' }
    ],
    recommendproduct:[
      { title: '产品名称1', price: '19.99', imgsrc: '../../resource/image/cp1.jpg', id:'1'},
      { title: '产品名称2', price: '19.99', imgsrc: '../../resource/image/cp2.jpg', id:'2'},
      { title: '产品名称3', price: '19.99', imgsrc: '../../resource/image/cp5.jpg', id:'3'},
      { title: '产品名称4', price: '19.99', imgsrc: '../../resource/image/cp6.jpg', id:'4'}
    ]
  },
  // 分享
  onShareAppMessage: function () {
    return {
      title: '餐饮酒店B2B云智能采购平台小程序!',
      desc: '众源实业'
    }
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  navclick:function(e){
    this.setData({'clicknum':e.currentTarget.dataset.index})
  },
  onLoad: function () {

    if (app.globalData.userInfo) {
      this.setData({
        userInfo: app.globalData.userInfo,
        hasUserInfo: true
      })
    } else if (this.data.canIUse){
      // 由于 getUserInfo 是网络请求，可能会在 Page.onLoad 之后才返回
      // 所以此处加入 callback 以防止这种情况
      app.userInfoReadyCallback = res => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    } else {
      // 在没有 open-type=getUserInfo 版本的兼容处理
      wx.getUserInfo({
        success: res => {
          app.globalData.userInfo = res.userInfo
          this.setData({
            userInfo: res.userInfo,
            hasUserInfo: true
          })
        }
      })
    }
  },
  getUserInfo: function(e) {
    console.log(e)
    app.globalData.userInfo = e.detail.userInfo
    this.setData({
      userInfo: e.detail.userInfo,
      hasUserInfo: true
    })
  },
  gosearch: function () {
    wx.navigateTo({
      // url: '../jobDetail/jobDetail?id=' + that.data.org_id,
      url: '../searchpage/searchpage'
    })
  },
  share: function () {
    wx.showShareMenu({
      withShareTicket: true
    })
  }
  // onPageScroll: function (e) {
  //   console.log(e)
  //   if (e.scrollTop > 100) {
  //     this.setData({
  //       floorstatus: true
  //     });
  //   } else {
  //     this.setData({
  //       floorstatus: false
  //     });
  //   }
  // },

  // //回到顶部
  // gotop: function (e) {  // 一键回到顶部
  //   if (wx.pageScrollTo) {
  //     wx.pageScrollTo({
  //       scrollTop: 0
  //     })
  //   } else {
  //     wx.showModal({
  //       title: '提示',
  //       content: '当前微信版本过低，无法使用该功能，请升级到最新微信版本后重试。'
  //     })
  //   }
  // }
  
})
